package chis.dip.map;

import chis.dip.fragments.MyNewMapFragment;

import android.os.Bundle;
import android.app.Activity;
import android.app.FragmentManager;
import android.view.Menu;

public class MapActivity extends Activity  {

	private MyNewMapFragment mapFrag;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.map_activity);
		
		// find the retained fragment on activity restarts
        FragmentManager fm = getFragmentManager();
        mapFrag = (MyNewMapFragment) fm.findFragmentByTag("mapFrag");

        // create the fragment and data the first time
        if (mapFrag == null) {
            // add the fragment
        	mapFrag = new MyNewMapFragment();
            fm.beginTransaction().add(mapFrag, "mapFrag").commit();
        }
		
	}
	
	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.main, menu);
		return true;
	}
	
//	@Override
//	public void onDestroy() {
//		super.onDestroy();
//		mapFrag.getFeatures().saveUserFeatures();
//	}
	
	@Override
	public void onStop() {
		super.onStop();
		mapFrag.getFeatures().saveUserFeatures();
	}
	

}
